package com.tfswx.jcyw.ruleenginedesigner.api;

import com.tfswx.jcyw.ruleenginedesigner.bean.ApiResult;
import com.tfswx.jcyw.ruleenginedesigner.dto.stgxgl.StgxAddInputDTO;
import com.tfswx.jcyw.ruleenginedesigner.dto.stgxgl.StgxDeleteInputDTO;
import com.tfswx.jcyw.ruleenginedesigner.dto.stgxgl.StgxListByXmbmQueryInputDTO;
import com.tfswx.jcyw.ruleenginedesigner.dto.stgxgl.StgxListByXmbmQueryOutputDTO;
import com.tfswx.jcyw.ruleenginedesigner.service.StgxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ricky
 * @date 2021/7/2
 */
@RestController
@RequestMapping("/stgxgl")
@Api(tags = "实体关系管理")
public class StgxglController {

    @Resource
    private StgxService stgxService;

    @ApiOperation("根据项目编码获取实体关系列表")
    @PostMapping("/queryStgxListByXmbm")
    public ApiResult<List<StgxListByXmbmQueryOutputDTO>> queryStgxListByXmbm(@RequestBody @Validated StgxListByXmbmQueryInputDTO stgxListByXmbmQueryInputDTO) {
        List<StgxListByXmbmQueryOutputDTO> stgxList = stgxService.queryStgxListByXmbm(stgxListByXmbmQueryInputDTO);
        return ApiResult.success(stgxList);
    }

    @ApiOperation("添加实体关系")
    @PostMapping("/addStgx")
    public ApiResult<Boolean> addStgx(@RequestBody @Validated StgxAddInputDTO stgxAddInputDTO) {
        boolean isSucc = stgxService.addStgx(stgxAddInputDTO);
        return ApiResult.success(isSucc);
    }

    @ApiOperation("删除实体关系")
    @PostMapping("/deleteStgx")
    public ApiResult<Boolean> deleteStgx(@RequestBody @Validated StgxDeleteInputDTO stgxDeleteInputDTO) {
        boolean isSucc = stgxService.deleteStgx(stgxDeleteInputDTO);
        return ApiResult.success(isSucc);
    }
}
